import 'package:dio/dio.dart';

class FavoriteAPI {
  final Dio _dio;

  FavoriteAPI(this._dio);

  // 添加收藏
  Future<dynamic> add(int id) async {
    FormData formData = FormData.fromMap({
      "id": id,
      "category": 'product'
    });

    Response res = await _dio.post('/collect/add', data: formData);

    return res.data;
  }

  // 取消收藏
  Future<dynamic> del(int id) async {
    FormData formData = FormData.fromMap({
      "id": id,
      "category": 'product'
    });
    
    Response res = await _dio.post('/collect/del', data: formData);

    return res.data;
  }

  // 收藏列表
  Future<dynamic> list() async {
    Response res = await _dio.get('/collect/user');

    return res.data;
  }
}